/******************************************************************************
 * $Id: types.h,v 1.5 2004/09/22 01:14:28 jimb Exp $
 * @file
 * @author  Jim Brooks http://www.jimbrooks.org
 ******************************************************************************/

#ifndef TYPES_H
#define TYPES_H

/******************************************************************************
 * structs/typedefs
 ******************************************************************************/

/**
 *-----------------------------------------------------------------------------
 * @brief Tag structs define tagged elements of source code.
 * @verbatim
 * Function call graph (used to construct a tree view):
 *
 * module hash table --+
 *                     |
 *                     +--> GSList of funcDef_t --+
 *                                                |
 *                                                +--> GSList of funcCall_t
 *
 * ############################################################
 * #   Some members point to dynamically allocated strings.   #
 * #   Some members point to static strings.                  #
 * #   Deallocating a tag_t struct will be quite complicated. #
 * ############################################################
 * @endverbatim
 *-----------------------------------------------------------------------------*/
typedef struct
{
   char*	pName;			/* name of the tag */
   char*	pType;			/* type of tag, eg "func", "define", etc */
   int		lineInt;		/* which line (in integer form 1 to ... ) */
   char*	pModuleName;	/* name of module the tag is in */
} tag_t;

/**
 * @brief Defines a module (src file).
 * This is stored in the module hash table.
 */
typedef struct
{
   gchar*		pModuleName;
   gchar*		pModuleBuffer;
   guint		moduleSize;
   gboolean		modified;   			/* for later when/if editing is supported */
   GSList*		pGslistFuncDef;
   GHashTable*	pHashFuncTags;			/* hashed tag_t structs of funcs/macros/methods */
   gchar		lineEnding;					/* LF=0, CR=1,LFCR=2 */
   const gchar	*pCharset;/* The module(file)'s default charset*/
   // language type
} module_t;

/**
 * For opened modules(files) currently.
 */
typedef struct
{
	module_t	* pModule;		/* which module opened */
	GtkWidget	* pNotebook;	/* Hold the module */
}module_opened_t;

/**
 * @brief Defines a function call that was parsed (within a function definition).
 *
 * A Gslist of these structs is pointed to by funcDef_t.pGslistFuncCall.
 * @remarks If a func def/call wasn't tagged by ctags (tag lookup fails),
 *          then pTag* will point to an _unlinked_ fabricated tag_t struct.
 */
typedef struct
{
   tag_t*		pTagFuncCall;		/* (see above note) points to tag of called function */
} funcCall_t;

/**
 * @brief Defines a function definition that was parsed.
 *
 * A Gslist of these structs is pointed to by module_t.pGslistFuncDef.
 */
typedef struct
{
   tag_t*		pTagFuncDef;		/* (see above note) points to function definition's tag */
   GSList*		pGslistFuncCall;
   int			lineStart;			/* line which func def begins */
   int			lineLast;			/* line which func def ends */
} funcDef_t;

typedef struct
{
   GtkWidget* pWidget;
   char       str[256];
   gboolean   focus;
   guint      fontHeight;
} focusbar_t;

/**
 * @brief Defines the position of the cursor in a module.
 */
typedef struct
{
   gboolean		valid;						/* true if members hold valid values */
   GtkWidget*	pWidgetText;				/* which text widget */
   gfloat		adjustmentValue;			/* value from text widget's GtkAdjustment widget */
   guint		idxCursor;					/* index of the cursor within the text */
   char			module[MAX_FILENAME_LEN];
} cursor_t;

/**
 * @brief Type for locking arbitrary resources.
 */
typedef gboolean lock_t;

/******************************************************************************
 * typedefs
 ******************************************************************************/

/**
 * For ptrs to strcmp() or strcase().
 */
typedef int FUNC_STRCMPX( const char* s1, const char *s2, size_t n);
typedef FUNC_STRCMPX* P_FUNC_STRCMPX;

/*
 * Misc. typedefs.
 */
typedef void FUNC(void);
typedef FUNC* PFUNC;

#endif /* TYPES_H */
